#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int a[25][25][25], x, y, z, n, x1, y1, z1, x2, y2, z2, ans = 0;
	cin >> x >> y >> z;
	cin >> n;
	for (int t = 1; t <= n; t++)
	{
		cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
		for (int i = x1; i <= x2; i++)
		{
			for (int j = y1; j <= y2; j++)
			{
				for (int k = z1; k <= z2; k++)
				{
					a[i][j][k] = 1;
				}
			}
		}
	}
	for (int i = 1; i <= x; i++)
	{
		for (int j = 1; j <= y; j++)
		{
			for (int k = 1; k <= z; k++)
			{
				if (a[i][j][k]==0)
				{
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}